package com.remedios.bugHandle.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import com.ruoyi.system.api.domain.SubmitBug;
import com.remedios.bugHandle.service.ISubmitBugService;
import com.ruoyi.common.log.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * BUG提交Controller
 * 
 * @author remedios
 * @date 2022-08-25
 */
@RestController
@RequestMapping("/bugHandle")
public class SubmitBugController extends BaseController
{
    @Autowired
    private ISubmitBugService submitBugService;

    /**
     * 查询BUG提交列表
     */
    @RequiresPermissions("bugHandle:bugHandle:list")
    @GetMapping("/list")
    public TableDataInfo list(SubmitBug submitBug)
    {
        startPage();
        List<SubmitBug> list = submitBugService.selectSubmitBugList(submitBug);
        return getDataTable(list);
    }

    /**
     * 导出BUG提交列表
     */
    @RequiresPermissions("bugHandle:bugHandle:export")
    @Log(title = "BUG提交", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SubmitBug submitBug)
    {
        List<SubmitBug> list = submitBugService.selectSubmitBugList(submitBug);
        ExcelUtil<SubmitBug> util = new ExcelUtil<SubmitBug>(SubmitBug.class);
        util.exportExcel(response, list, "BUG提交数据");
    }

    /**
     * 获取BUG提交详细信息
     */
    @RequiresPermissions("bugHandle:bugHandle:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(submitBugService.selectSubmitBugById(id));
    }

    /**
     * 新增BUG提交
     */
    @RequiresPermissions("bugHandle:bugHandle:add")
    @Log(title = "BUG提交", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubmitBug submitBug)
    {
        return toAjax(submitBugService.insertSubmitBug(submitBug));
    }

    /**
     * 修改BUG提交
     */
    @RequiresPermissions("bugHandle:bugHandle:edit")
    @Log(title = "BUG提交", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubmitBug submitBug)
    {
        return toAjax(submitBugService.updateSubmitBug(submitBug));
    }

    /**
     * 删除BUG提交
     */
    @RequiresPermissions("bugHandle:bugHandle:remove")
    @Log(title = "BUG提交", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(submitBugService.deleteSubmitBugByIds(ids));
    }

    /**
     * 处理BUG提交
     */
    @RequiresPermissions("bugHandle:bugHandle:remove")
    @Log(title = "处理BUG提交", businessType = BusinessType.DELETE)
    @PutMapping("/{ids}")
    public AjaxResult responseUpdate(@PathVariable Integer[] ids)
    {

        return toAjax(submitBugService.responseSubmitBugByIds(ids));
    }
}
